package com.zsk.shop.enums;

import com.zsk.shop.common.enums.EnumType;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 用户现金相关交易类型
 * 1门票收入/2提现/3拉新获取···
 *
 * @author ljh
 * @create 2021/5/14 11:40
 */
public enum EnumUserAccountChangeType {
    REPAIR("修正账户", -1, "系统修正账户"),
    INIT("初始化账户", 0, "新账户生成"),

    POINT_TO_ACCOUNT("积分解冻", 1, "会议流量红包"),

    PARENT_FIRST("直推奖励", 10, "会员商城奖励"),
    PARENT_SECOND("间推奖励", 11, "会员商城奖励"),

    WITHDRAWAL("提现", 21, "您发起提现s%元"),
    WITHDRAWAL_SUCCESS("提现成功", 22, "提现成功s%元"),
    WITHDRAWAL_FAIL("提现失败", 23, "提现失败，退回冻结s%元"),

    FINANCE_ADD("手动增加余额", 80, "收到审核红包补贴"),
    FINANCE_ADD_REMARK("手动增加余额", 81, "见备注"),
    FINANCE_REPAIR_REMARK("修正账户", -81, "见备注"),
    FINANCE_ADD_REMARK_COMMISSION("手动增加余额上级提成", 82, "见备注"),

    OTHER("", -100, "其他");

    private String name;
    private Integer code;
    private String content;

    EnumUserAccountChangeType(String name, Integer code, String content) {
        this.name = name;
        this.code = code;
        this.content = content;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public static String getContentByCode(Integer code) {
        EnumUserAccountChangeType[] enums = EnumUserAccountChangeType.values();
        for (int i = 0; i < enums.length; i++) {
            if (enums[i].getCode().equals(code)) {
                return enums[i].getContent();
            }
        }
        return "";
    }

    public static List<EnumType> getList() {
        List<EnumType> result = new ArrayList<>();
        EnumUserAccountChangeType[] enums = EnumUserAccountChangeType.values();
        List<Integer> exceptCode = Arrays.asList(0, 4, 5);
        for (int i = 0; i < enums.length; i++) {
            EnumType enumType = new EnumType();
            enumType.setCode(enums[i].getCode());
            enumType.setName(enums[i].getName());
            if (!exceptCode.contains(enums[i].getCode())) {
                result.add(enumType);
            }
        }
        return result;
    }

}
